﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;
using System.Text;

namespace finalexam
{
    public partial class WebForm9 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void BtnUpade_Click(object sender, EventArgs e)
        {
            string strCn = "server=pc.hstc.cn;database=dhd2014112134;uid=2014112134;pwd=19951124";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();
                StringBuilder SqlStringBuilder = new StringBuilder(1024);
                SqlStringBuilder.Append("UPDATE  UserTea ");
                SqlStringBuilder.AppendFormat("SET Password = N'{0}'", this.txtNPwd.Text);
                SqlStringBuilder.AppendFormat("WHERE   (UserName = N'{0}') ", this.txtUserName.Text);


                string strSql = SqlStringBuilder.ToString();
                SqlCommand cmd = new SqlCommand(strSql, cn);

                int iUpd = cmd.ExecuteNonQuery();
                if (iUpd < 1)
                {
                    this.Label8.Text = "修改失败！";
                }
                else
                {
                    this.Label8.Text = "修改成功！您的新密码是：" + this.txtNPwd.Text;
                    this.txtNPwd.Text = "";
                }
            }
            catch (Exception ex)
            {
                this.Label8.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }

        protected void BtnEmpty_Click(object sender, EventArgs e)
        {
            this.txtUserName.Text = "";
            this.txtNPwd.Text = "";
            this.txtRPwd.Text = "";
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["Theme"] = this.DropDownList1.SelectedValue.ToString();
        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["Theme"] != null)
                this.Theme = Session["Theme"].ToString();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

        }
    }
}